﻿using DWH.PP.Push;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Collections.Generic;
using DWH.Utils;

namespace RDTest
{
    
    
    /// <summary>
    ///This is a test class for PageImageDownloadWorkerTest and is intended
    ///to contain all PageImageDownloadWorkerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PageImageDownloadWorkerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for DoWork
        ///</summary>
        [TestMethod()]
        public void DoWorkTest()
        {
            PageImageDownloadWorker target = new PageImageDownloadWorker();
            target.TaskName = "UT for PageImageDownloadWorker";            
            target.WorkerInstanceCount = 1;

            for (int i = 99; i < 299; i++)
            {
                //target.ProcessingCollection.Add("initial item:" + i.ToString());
            }

            target.Initialize();
            target.Run();

            Thread.Sleep(100 * 1000);
        }

        /// <summary>
        ///A test for DoWork
        ///</summary>
        [TestMethod()]
        public void DownloadImgTest()
        {
            PageImageDownloadWorker target = new PageImageDownloadWorker();

            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "DBImagePushTask" + newId.ToString();

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_WORKER_BATCH_COUNT] = "10";
            target.ExtendData[DWHConstants.KEY_WORKER_INSTANCE_COUNT] = "2";

            target.Initialize();
            target.Run();

            Thread.Sleep(100 * 1000);
        }
    }
}
